package fourfaith.com.ff_sl21_app.utils;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.TextView;

import fourfaith.com.ff_sl21_app.R;

/**
 * 自定义加载进度对话框
 * Created by Administrator on 2017-05-11.
 */

public class LoadingDialog extends Dialog {
    private TextView tipTextView;

    public LoadingDialog(Context context) {
        super(context);
        /**设置对话框背景透明*/

        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setContentView(R.layout.loading_dialog);

        //去除dialog title divider线
        try {
            int dividerID = context.getResources().getIdentifier("android:id/titleDivider", null, null);
            View divider = findViewById(dividerID);
            divider.setBackgroundColor(Color.TRANSPARENT);
        } catch (Exception e) {

        }

        tipTextView = (TextView) findViewById(R.id.tipTextView);
        setCanceledOnTouchOutside(false);
    }

    /**
     * 为加载进度个对话框设置不同的提示消息
     *
     * @param message 给用户展示的提示信息
     * @return build模式设计，可以链式调用
     */

    public LoadingDialog setMessage(String message) {
        tipTextView.setText(message);
        return this;
    }

}
